package com.openbravo.data.loader;

import java.util.Comparator;

public class ComparatorCreatorBasic
  implements ComparatorCreator
{
  private String[] m_sHeaders;
  private Datas[] m_aDatas;
  private int[] m_iAvailableIndexes;

  public ComparatorCreatorBasic(String[] paramArrayOfString, Datas[] paramArrayOfDatas, int[] paramArrayOfInt)
  {
    this.m_sHeaders = paramArrayOfString;
    this.m_aDatas = paramArrayOfDatas;
    this.m_iAvailableIndexes = paramArrayOfInt;
  }

  public ComparatorCreatorBasic(String[] paramArrayOfString, Datas[] paramArrayOfDatas)
  {
    this.m_sHeaders = paramArrayOfString;
    this.m_aDatas = paramArrayOfDatas;
    this.m_iAvailableIndexes = new int[paramArrayOfDatas.length];
    for (int i = 0; i < paramArrayOfDatas.length; i++)
      this.m_iAvailableIndexes[i] = i;
  }

  public String[] getHeaders()
  {
    String[] arrayOfString = new String[this.m_iAvailableIndexes.length];
    for (int i = 0; i < this.m_iAvailableIndexes.length; i++)
      arrayOfString[i] = this.m_sHeaders[this.m_iAvailableIndexes[i]];
    return arrayOfString;
  }

  public Comparator createComparator(int[] paramArrayOfInt)
  {
    return new ComparatorBasic(paramArrayOfInt);
  }

  public class ComparatorBasic
    implements Comparator
  {
    private int[] m_aiOrderBy;

    public ComparatorBasic(int[] arg2)
    {
      Object localObject;
      this.m_aiOrderBy = arg2;
    }

    public int compare(Object paramObject1, Object paramObject2)
    {
      if (paramObject1 == null)
      {
        if (paramObject2 == null)
          return 0;
        return -1;
      }
      if (paramObject2 == null)
        return 1;
      Object[] arrayOfObject1 = (Object[])(Object[])paramObject1;
      Object[] arrayOfObject2 = (Object[])(Object[])paramObject2;
      for (int i = 0; i < this.m_aiOrderBy.length; i++)
      {
        int j = ComparatorCreatorBasic.this.m_aDatas[ComparatorCreatorBasic.this.m_iAvailableIndexes[this.m_aiOrderBy[i]]].compare(arrayOfObject1[ComparatorCreatorBasic.this.m_iAvailableIndexes[this.m_aiOrderBy[i]]], arrayOfObject2[ComparatorCreatorBasic.this.m_iAvailableIndexes[this.m_aiOrderBy[i]]]);
        if (j != 0)
          return j;
      }
      return 0;
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.loader.ComparatorCreatorBasic
 * JD-Core Version:    0.6.0
 */